package creator

import (
	"fmt"
	"gitee.com/kristas/booting-go/framework/common/util/lang"
	"os"
	"path/filepath"
)

type GoFile struct {
	*File
}

func NewGoFile(template, pkg, fileName string, skipIfExists bool) *GoFile {
	wd, err := os.Getwd()
	if err != nil {
		panic(err)
	}
	f := &File{
		Wd:           filepath.Join(wd, pkg),
		Template:     template,
		Ext:          "go",
		SkipIfExists: skipIfExists,
		Data:         nil,
		FileName:     lang.NewString(fileName).SnakeCase().String(),
		PostHandler: func(file *File) {

		},
	}

	if f.SkipIfExists {
		f.SetAttribute("GenerateTitle", fmt.Sprintf("Package %s Code Generated by booctl; SKIP IF EXISTS.", pkg))
	} else {
		f.SetAttribute("GenerateTitle", fmt.Sprintf("Package %s Code Generated by booctl; DO NOT EDIT.", pkg))
	}
	return &GoFile{
		File: f,
	}
}

type StructureGoFile struct {
}
